
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
  "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml" lang="zh_Hans">
  <head>
    <meta http-equiv="X-UA-Compatible" content="IE=Edge" />
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <title>表单 &#8212; Django 3.2.11.dev 文档</title>
    <link rel="stylesheet" href="../../_static/default.css" type="text/css" />
    <link rel="stylesheet" href="../../_static/pygments.css" type="text/css" />
    <script type="text/javascript" id="documentation_options" data-url_root="../../" src="../../_static/documentation_options.js"></script>
    <script type="text/javascript" src="../../_static/jquery.js"></script>
    <script type="text/javascript" src="../../_static/underscore.js"></script>
    <script type="text/javascript" src="../../_static/doctools.js"></script>
    <script type="text/javascript" src="../../_static/language_data.js"></script>
    <link rel="index" title="索引" href="../../genindex.html" />
    <link rel="search" title="搜索" href="../../search.html" />
    <link rel="next" title="表单 API" href="api.html" />
    <link rel="prev" title="上传的文件和上传处理程序" href="../files/uploads.html" />



 
<script src="../../templatebuiltins.js"></script>
<script>
(function($) {
    if (!django_template_builtins) {
       // templatebuiltins.js missing, do nothing.
       return;
    }
    $(document).ready(function() {
        // Hyperlink Django template tags and filters
        var base = "../templates/builtins.html";
        if (base == "#") {
            // Special case for builtins.html itself
            base = "";
        }
        // Tags are keywords, class '.k'
        $("div.highlight\\-html\\+django span.k").each(function(i, elem) {
             var tagname = $(elem).text();
             if ($.inArray(tagname, django_template_builtins.ttags) != -1) {
                 var fragment = tagname.replace(/_/, '-');
                 $(elem).html("<a href='" + base + "#" + fragment + "'>" + tagname + "</a>");
             }
        });
        // Filters are functions, class '.nf'
        $("div.highlight\\-html\\+django span.nf").each(function(i, elem) {
             var filtername = $(elem).text();
             if ($.inArray(filtername, django_template_builtins.tfilters) != -1) {
                 var fragment = filtername.replace(/_/, '-');
                 $(elem).html("<a href='" + base + "#" + fragment + "'>" + filtername + "</a>");
             }
        });
    });
})(jQuery);</script>

  </head><body>

    <div class="document">
  <div id="custom-doc" class="yui-t6">
    <div id="hd">
      <h1><a href="../../index.html">Django 3.2.11.dev 文档</a></h1>
      <div id="global-nav">
        <a title="Home page" href="../../index.html">Home</a>  |
        <a title="Table of contents" href="../../contents.html">Table of contents</a>  |
        <a title="Global index" href="../../genindex.html">Index</a>  |
        <a title="Module index" href="../../py-modindex.html">Modules</a>
      </div>
      <div class="nav">
    &laquo; <a href="../files/uploads.html" title="上传的文件和上传处理程序">previous</a>
     |
    <a href="../index.html" title="API 参考" accesskey="U">up</a>
   |
    <a href="api.html" title="表单 API">next</a> &raquo;</div>
    </div>

    <div id="bd">
      <div id="yui-main">
        <div class="yui-b">
          <div class="yui-g" id="ref-forms-index">
            
  <div class="section" id="s-forms">
<span id="forms"></span><h1>表单<a class="headerlink" href="#forms" title="永久链接至标题">¶</a></h1>
<p>详细的表单 API 参考。关于介绍性材料，请参见 <a class="reference internal" href="../../topics/forms/index.html"><span class="doc">使用表单</span></a> 主题指南。</p>
<div class="toctree-wrapper compound">
<ul>
<li class="toctree-l1"><a class="reference internal" href="api.html">表单 API</a><ul>
<li class="toctree-l2"><a class="reference internal" href="api.html#bound-and-unbound-forms">绑定和非绑定表单</a></li>
<li class="toctree-l2"><a class="reference internal" href="api.html#using-forms-to-validate-data">使用表单来验证数据</a></li>
<li class="toctree-l2"><a class="reference internal" href="api.html#initial-form-values">初始表单值</a></li>
<li class="toctree-l2"><a class="reference internal" href="api.html#checking-which-form-data-has-changed">检查哪些表格数据已经改变</a></li>
<li class="toctree-l2"><a class="reference internal" href="api.html#accessing-the-fields-from-the-form">访问表单中的字段</a></li>
<li class="toctree-l2"><a class="reference internal" href="api.html#accessing-clean-data">访问“干净的”数据</a></li>
<li class="toctree-l2"><a class="reference internal" href="api.html#outputting-forms-as-html">将表单输出为 HTML</a></li>
<li class="toctree-l2"><a class="reference internal" href="api.html#more-granular-output">更精细的输出</a></li>
<li class="toctree-l2"><a class="reference internal" href="api.html#customizing-boundfield">自定义 <code class="docutils literal notranslate"><span class="pre">BoundField</span></code></a></li>
<li class="toctree-l2"><a class="reference internal" href="api.html#binding-uploaded-files-to-a-form">将上传的文件绑定到表单中</a></li>
<li class="toctree-l2"><a class="reference internal" href="api.html#subclassing-forms">子类化表单</a></li>
<li class="toctree-l2"><a class="reference internal" href="api.html#prefixes-for-forms">表单前缀</a></li>
</ul>
</li>
<li class="toctree-l1"><a class="reference internal" href="fields.html">表单字段</a><ul>
<li class="toctree-l2"><a class="reference internal" href="fields.html#core-field-arguments">核心字段参数</a></li>
<li class="toctree-l2"><a class="reference internal" href="fields.html#checking-if-the-field-data-has-changed">检查字段数据是否有变化</a></li>
<li class="toctree-l2"><a class="reference internal" href="fields.html#built-in-field-classes">内置 <code class="docutils literal notranslate"><span class="pre">Field</span></code> 类</a></li>
<li class="toctree-l2"><a class="reference internal" href="fields.html#slightly-complex-built-in-field-classes">稍复杂的内置 <code class="docutils literal notranslate"><span class="pre">Field</span></code> 类</a></li>
<li class="toctree-l2"><a class="reference internal" href="fields.html#fields-which-handle-relationships">处理关系的字段</a></li>
<li class="toctree-l2"><a class="reference internal" href="fields.html#creating-custom-fields">创建自定义字段</a></li>
</ul>
</li>
<li class="toctree-l1"><a class="reference internal" href="models.html">模型表单函数</a><ul>
<li class="toctree-l2"><a class="reference internal" href="models.html#modelform-factory"><code class="docutils literal notranslate"><span class="pre">modelform_factory</span></code></a></li>
<li class="toctree-l2"><a class="reference internal" href="models.html#modelformset-factory"><code class="docutils literal notranslate"><span class="pre">modelformset_factory</span></code></a></li>
<li class="toctree-l2"><a class="reference internal" href="models.html#inlineformset-factory"><code class="docutils literal notranslate"><span class="pre">inlineformset_factory</span></code></a></li>
</ul>
</li>
<li class="toctree-l1"><a class="reference internal" href="formsets.html">表单集函数</a><ul>
<li class="toctree-l2"><a class="reference internal" href="formsets.html#formset-factory"><code class="docutils literal notranslate"><span class="pre">formset_factory</span></code></a></li>
</ul>
</li>
<li class="toctree-l1"><a class="reference internal" href="renderers.html">表单渲染 API</a><ul>
<li class="toctree-l2"><a class="reference internal" href="renderers.html#the-low-level-render-api">低级渲染 API</a></li>
<li class="toctree-l2"><a class="reference internal" href="renderers.html#built-in-template-form-renderers">内置模板表单渲染器</a></li>
<li class="toctree-l2"><a class="reference internal" href="renderers.html#context-available-in-widget-templates">部件模板中可用的上下文</a></li>
<li class="toctree-l2"><a class="reference internal" href="renderers.html#overriding-built-in-widget-templates">覆盖内置部件模板</a></li>
</ul>
</li>
<li class="toctree-l1"><a class="reference internal" href="widgets.html">部件</a><ul>
<li class="toctree-l2"><a class="reference internal" href="widgets.html#specifying-widgets">指定部件</a></li>
<li class="toctree-l2"><a class="reference internal" href="widgets.html#setting-arguments-for-widgets">为部件设置参数</a></li>
<li class="toctree-l2"><a class="reference internal" href="widgets.html#widgets-inheriting-from-the-select-widget">继承自 <code class="docutils literal notranslate"><span class="pre">Select</span></code> 部件的部件。</a></li>
<li class="toctree-l2"><a class="reference internal" href="widgets.html#customizing-widget-instances">自定义部件实例</a></li>
<li class="toctree-l2"><a class="reference internal" href="widgets.html#base-widget-classes">基础部件类</a></li>
<li class="toctree-l2"><a class="reference internal" href="widgets.html#built-in-widgets">内置部件</a></li>
</ul>
</li>
<li class="toctree-l1"><a class="reference internal" href="validation.html">表单和字段验证</a><ul>
<li class="toctree-l2"><a class="reference internal" href="validation.html#raising-validationerror">引发 <code class="docutils literal notranslate"><span class="pre">ValidationError</span></code></a></li>
<li class="toctree-l2"><a class="reference internal" href="validation.html#using-validation-in-practice">在实践中使用验证</a></li>
</ul>
</li>
</ul>
</div>
</div>


          </div>
        </div>
      </div>
      
        
          <div class="yui-b" id="sidebar">
            
      <div class="sphinxsidebar" role="navigation" aria-label="main navigation">
        <div class="sphinxsidebarwrapper">
  <h4>上一个主题</h4>
  <p class="topless"><a href="../files/uploads.html"
                        title="上一章">上传的文件和上传处理程序</a></p>
  <h4>下一个主题</h4>
  <p class="topless"><a href="api.html"
                        title="下一章">表单 API</a></p>
  <div role="note" aria-label="source link">
    <h3>本页</h3>
    <ul class="this-page-menu">
      <li><a href="../../_sources/ref/forms/index.txt"
            rel="nofollow">显示源代码</a></li>
    </ul>
   </div>
<div id="searchbox" style="display: none" role="search">
  <h3>快速搜索</h3>
    <div class="searchformwrapper">
    <form class="search" action="../../search.html" method="get">
      <input type="text" name="q" />
      <input type="submit" value="转向" />
      <input type="hidden" name="check_keywords" value="yes" />
      <input type="hidden" name="area" value="default" />
    </form>
    </div>
</div>
<script type="text/javascript">$('#searchbox').show(0);</script>
        </div>
      </div>
              <h3>Last update:</h3>
              <p class="topless">12月 07, 2021</p>
          </div>
        
      
    </div>

    <div id="ft">
      <div class="nav">
    &laquo; <a href="../files/uploads.html" title="上传的文件和上传处理程序">previous</a>
     |
    <a href="../index.html" title="API 参考" accesskey="U">up</a>
   |
    <a href="api.html" title="表单 API">next</a> &raquo;</div>
    </div>
  </div>

      <div class="clearer"></div>
    </div>
  </body>
</html>